package com.shycloud.mido.member.pattern;

import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import com.shycloud.mido.common.core.exception.BusinessException;
import com.shycloud.mido.common.core.util.SpringContextHolder;
import com.shycloud.mido.member.api.util.Constant;
/**
 * 天天帮分配工厂
 *
 * @Description: getSubjectStrategy
 * @param subject
 * @return
 * @author baiqiang.
 * @date 2021年7月13日 下午5:29:43 
 * @version V1.0
 */
public class SubjectStrategyFactory {
	
	private Map<String, ISubjectStrategy> strategyMap;
	
	public SubjectStrategyFactory configStrategy(Map<String, ISubjectStrategy> strategyMap) {
		this.strategyMap = strategyMap;
		return this;
	}
	/**
	 * 获取分配方式
	 *
	 * @Description: getSubjectStrategy
	 * @param subjectStrategy
	 * @return
	 * @author baiqiang.
	 * @date 2021年7月13日 下午5:30:03 
	 * @version V1.0
	 */
	public ISubjectStrategy getSubjectStrategy(String subjectStrategy) {
		return Optional.ofNullable(strategyMap).map(s -> s.get(subjectStrategy)).orElseThrow(() -> new BusinessException("未找到策略"));
	}
	
}
